package ExamSystemClient.managerSystem.studentManagement;

import ExamSystemClient.client.ClientScanner;
import ExamSystemClient.model.Student;

import java.util.List;
import java.util.Scanner;

/**
 * 修改信息
 *
 * @author huangshuxian
 */
public class ModifyStudent extends StudentInfoManage {

    public ModifyStudent(List<Student> studentInfos) {
        super(studentInfos);
    }

    @Override
    public void operate() {
        //1、提示用户输入需要修改的学生学号
        System.out.println("请输入需要修改的学生学号：");
        int index = getIndexByNumber(ClientScanner.getScanner().nextInt());
        if (index >= 0){
            //2、提示用户输入需要修改的信息
            Student student = studentInfos.get(index);
            System.out.println("请输入需要修改的信息：");
            String modifyInfoName = ClientScanner.getScanner().next();
            //只修改姓名和年龄
            switch(modifyInfoName){
                case "姓名":
                    student.setUserName(ClientScanner.getScanner().next());
                    break;
                case "年龄":
                    student.setAge(ClientScanner.getScanner().nextInt());
                    break;
                    default:
            }
            System.out.println("修改信息成功！");
            System.out.println("修改后的信息为：" + student);
        }else{
            System.out.println("输入的学号信息找不到匹配的数据！");
        }


    }

    @Override
    public ModifyStudent show() {
        System.out.println("修改学生信息！");
        return this;
    }
}
